<template>
	<view class="tn-safe-area-inset-bottom container">
		<!-- 顶部自定义导航 -->
		<tn-nav-bar fixed customBack backgroundColor="#FFFFFF" id="navbar">
			<view slot="back" class='tn-custom-nav-bar__back' @click="goBack" style="opacity: 1;display: flex;">
				<text class='icon tn-icon-left'></text>
				<text class='icon tn-icon-discover-fill'></text>
			</view>
			<view class="tn-flex tn-flex-col-center tn-flex-row-center" style="opacity: 1;display: flex;">
				<view class="tn-text-bold tn-text-xl">{{title}}</view>
			</view>
		</tn-nav-bar>
		
		<view class="group-wrap tn-bg-white" style="padding-top: 150px;">
			<view class="" style="padding: 30rpx 20rpx;">
				<tn-waterfall ref="waterfall" v-model="list" @finish="handleWaterFallFinish">
					<template v-slot:left="{ leftList }">
						<view v-for="(item, index) in leftList" :key="index" class="product__item"
							@click="tn(item.url)">
							<view class="item__image">
								<tn-lazy-load :threshold="6000" height="100%" :image="item.url" :index="item.id"
									imgMode="widthFix"></tn-lazy-load>
							</view>
						</view>
					</template>
					<template v-slot:right="{ rightList }">
						<view v-for="(item, index) in rightList" :key="index" class="product__item"
							@click="tn(item.url)">
							<view class="item__image">
								<tn-lazy-load :threshold="6000" height="100%" :image="item.url" :index="item.id"
									imgMode="widthFix"></tn-lazy-load>
							</view>
						</view>
					</template>
				</tn-waterfall>
			</view>
			<tn-load-more :status="loadStatus"></tn-load-more>
		</view>
	</view>
</template>

<script>
	import template_page_mixin from '@/uni_modules/tuniao-ui/libs/mixin/template_page_mixin.js'
	import {
		listWeddingPhoto
	} from '@/api/common/api'
	export default {
		name: 'photoList',
		mixins: [template_page_mixin],
		data() {
			return {
				/* 瀑布流*/
				loadStatus: 'nomore',
				list: [],
				title:'',
				// 查询参数
				queryParams: {
					pageNum: 1,
					pageSize: 1000,
					typeId: undefined
				},
			}
		},

		onLoad(e) {
			this.queryParams.typeId = e.typeId
			this.getRandomData()
		},

		methods: {
			// 跳转
			tn(url) {
				uni.navigateTo({
					url: '/pages/home/photo/photo?url='+url,
				});
			},
			/* 瀑布流*/
			getRandomData() {
				this.loadStatus = 'loading'
				listWeddingPhoto(this.queryParams).then(response => {
					this.list=response.rows;
					this.title=response.rows[0].typeName
				});
			},
			// 瀑布流加载完毕事件
			handleWaterFallFinish() {
				this.loadStatus='nomore'
			},
		}
	}
</script>

<style lang="scss" scoped>
	.container{
		height: 100vh;
		overflow: scroll;
	}
	/* 胶囊*/
	.tn-custom-nav-bar__back {
		width: 100%;
		height: 100%;
		position: relative;
		display: flex;
		justify-content: space-evenly;
		align-items: center;
		box-sizing: border-box;
		background-color: rgba(0, 0, 0, 0.03);
		border-radius: 1000rpx;
		border: 1rpx solid rgba(255, 255, 255, 0.5);
		// color: #FFFFFF;
		font-size: 18px;

		.icon {
			display: block;
			flex: 1;
			margin: auto;
			text-align: center;
		}

		&:before {
			content: " ";
			width: 1rpx;
			height: 110%;
			position: absolute;
			top: 22.5%;
			left: 0;
			right: 0;
			margin: auto;
			transform: scale(0.5);
			transform-origin: 0 0;
			pointer-events: none;
			box-sizing: border-box;
			opacity: 0.05;
			background-color: #000000;
		}
	}

	/* 内容*/
	.group-wrap {
		position: relative;
		z-index: 1;
		// padding: 20rpx 30rpx;
		margin-top: -130rpx;
		margin-bottom: 40rpx;
		border-radius: 30rpx 30rpx 0 0;
	}


	/* 瀑布流*/
	.product__item {
		background-color: #FFFFFF;
		overflow: hidden;
		margin: 0 10rpx;
		margin-bottom: 20rpx;
		// box-shadow: 0rpx 0rpx 30rpx 0rpx rgba(0, 0, 0, 0.07);

		.item {

			/* 图片 start */
			&__image {
				width: 100%;
				height: auto;
				background-color: #FFFFFF;
				border: 1rpx solid #F8F7F8;
				border-radius: 10rpx;
				overflow: hidden;
			}

			/* 图片 end */
		}
	}
</style>
